﻿import datetime
import turtle


def draw_blank():
    turtle.penup()
    turtle.fd(5)


def draw_line(flag):
    draw_blank()
    if flag:
        turtle.pendown()
    else:
        turtle.penup()
    turtle.fd(40)
    draw_blank()
    turtle.right(90)


def draw_digit(digit):
    if digit in [2, 3, 4, 5, 6, 8, 9]:
        draw_line(True)
    else:
        draw_line(False)
    if digit in [0, 1, 3, 4, 5, 6, 7, 8, 9]:
        draw_line(True)
    else:
        draw_line(False)
    if digit in [0, 2, 3, 5, 6, 8]:
        draw_line(True)
    else:
        draw_line(False)
    if digit in [0, 2, 6, 8]:
        draw_line(True)
    else:
        draw_line(False)
    turtle.left(90)
    if digit in [0, 4, 5, 6, 8, 9]:
        draw_line(True)
    else:
        draw_line(False)
    if digit in [0, 2, 3, 5, 6, 7, 8, 9]:
        draw_line(True)
    else:
        draw_line(False)
    if digit in [0, 1, 2, 3, 4, 7, 8, 9]:
        draw_line(True)
    else:
        draw_line(False)


def draw_date(date):
    turtle.pencolor('red')
    for i in date:
        if i == '-':
            turtle.write('年', font=('Arial', 16, 'normal'))
            turtle.pencolor('green')
            turtle.fd(40)
        elif i == '&':
            turtle.write('月', font=('Arial', 16, 'normal'))
            turtle.pencolor('blue')
            turtle.fd(40)
        elif i == '#':
            turtle.write('日', font=('Arial', 16, 'normal'))
        else:
            draw_digit(eval(i))
            turtle.left(180)
            turtle.fd(20)


def main():
    turtle.setup(900, 400, 200, 200)
    turtle.pensize(5)
    turtle.speed(100)
    turtle.hideturtle()
    turtle.penup()
    turtle.bk(350)
    date = datetime.datetime.now().strftime('%Y-%m&%d#')
    draw_date(date)
    input()


main()
